import http from '@/service/http'
import config from '../config'

const baseUrl = config.USER_ADMIN_URL
const DATACENTER_PERMISSION = config.DATACENTER_PERMISSION

export const _getRouterList = apiId => http.$GET(`${DATACENTER_PERMISSION}/api/role/owner/${apiId}/menu`)
export const _postPageUserByCode = (params) => http.$POST(`${baseUrl}/user/pageUserByCode`, params)
export const _updateStatus = (id, status) => http.$PUT(`${baseUrl}/user/updateStatus/${id}/${status}`)
export const _deleteUser = (id) => http.$DELETE(`${baseUrl}/user/remove/${id}`)
export const _addUser = (params) => http.$POST(`${baseUrl}/user/add`, params)
export const _addAndEditUser = (params) => http.$POST(`${baseUrl}/user/add`, params)
export const _update = (params) => http.$PUT(`${baseUrl}/user/update`, params)

export const _postPageUserByCondition = (params) => http.$POST(`${baseUrl}/user/list`, params)
export const _getUserInfoBySn = (sn) => http.$GET(`${baseUrl}/user/get/${sn}`)
export const _getListUserOrganizationBySnAndType = (sn, organizationType) => http.$GET(`${baseUrl}/user/listUserOrganizationBySnAndType/${sn}/${organizationType}`)
export const _getListOrganizationChangeBySn = (sn) => http.$GET(`${baseUrl}/user/listOrganizationChangeBySn/${sn}`)
export const _getRolePermissions = (sn, code) => http.$GET(`${baseUrl}/user/getRolePermissions/${sn}/${code}`)
// 获取系统菜单
export const _getMenuByAppId = appId => http.$GET(`${DATACENTER_PERMISSION}/api/role/owner/${appId}/menu`)
//获取所有路由
export const _getAllRouter = (appId='35') => http.$GET(`${baseUrl}/role/owner/${appId}/router/all`)
//获取用户所属组织
export const _getUserOrgs = (params) => http.$GET(`${baseUrl}/user/orgs/${params}`)
//修改用户组织
export const _changeUserOrgs = (params) => http.$POST(`${baseUrl}/user/changeRef`, params)
export const _resetPassword = id => http.$GET(`${baseUrl}/user/resetPassword/${id}`)
//获取图片
export const _getBaseImage = (type) => http.$GET(`${baseUrl}/baseSetting/image/${type}`,{},{responseType: 'blob'})//1是登录背景2是logo
//获取基础信息
export const _getBaseInfo = () => http.$GET(`${baseUrl}/baseSetting/baseInfo`)
//保存基础配置
export const _saveSystemTheme = (params) => http.$POST(`${baseUrl}/baseSetting/save?id=${params.id}&theme=${params.theme}&style=${params.style}`,params.formData)
//查询自己在某应用某路由已授权按钮
export const _getAuthButton = (params) => http.$GET(`${baseUrl}/role/owner/${params.appId}/${params.routerId}/button`)
export const _getChangePassword = params => http.$POST(`${baseUrl}/user/updatePassword`, params)
export const _getUserInfo = params => http.$POST(`${baseUrl}/user/getLoginUserBaseInfo`)



